package com.itsu.mysql.service.impl;

import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.itsu.interfaces.entity.UserBlack;
import com.itsu.interfaces.service.UserBlackService;
import com.itsu.mysql.mappers.UserBlackMapper;
import org.apache.dubbo.config.annotation.Service;
import org.springframework.beans.factory.annotation.Autowired;


@Service
public class UserBlackServiceImpl implements UserBlackService {

    @Autowired
    UserBlackMapper userBlackMapper;

    @Override
    public Page<UserBlack> findBlackListByUid(Integer page, Integer pageSize, Long uid) {
        Page<UserBlack> selectPage = new Page<>(page - 1, pageSize);
        userBlackMapper.selectPage(selectPage, Wrappers.lambdaQuery(UserBlack.class).eq(UserBlack::getUserId, uid));
        return selectPage;
    }

    @Override
    public void deleteByUid(Long uid) {
        userBlackMapper.delete(Wrappers.lambdaQuery(UserBlack.class).eq(UserBlack::getBlackUserId, uid));
    }
}
